<!-- 圈子-树洞 -->
<template>
	<view class="item flex flex-column"  @click="link(item)">
		<view class="outer flex justify-between">
			<view class="left flex-shrink">
				<image :src="item.avatar" mode=""></image>
			</view>
			<view class="right">
				<view class="top">
					{{item.userName}}
				</view>
				<view class="texte">
					{{item.title}}
				</view>
				<view class="btmimg">
					<view v-if="!item.type" class="list flex flex-wrap justify-between">
						<view class="icon" v-for="(item, i) in item.hollowCommentContentList" :key="i">
							<image :src="item" mode="" @click.stop="preview(i)"></image>
						</view>
					</view>
					<view class="video" v-if="item.type">
						<video :src="item.hollowCommentContentList[0]" controls></video>
					</view>
				</view>
				<view class="positioning flex justify-between align-center" @click="link(item)" v-if="status == 0">
					<view class="date">
						{{commentNum}}人参与了评论
					</view>
					<view class="city">
						{{likeNum}}人参与了点赞
					</view>
				</view>
				<view class="positioning flex justify-between align-center" @click="link(item)" v-if="status == 1">
					<view class="date">
						{{commentNum}}人参与了评论
					</view>
					<view class="city flex align-center">
							<view class="le" v-if="!item.hollowListLikeType" @click="dianzan(item.hollowListId)">
								<image src="https://sanfuzhide.oss-cn-hangzhou.aliyuncs.com/circle/zan.png" mode=""></image>
							</view>
							<view class="le" v-if="item.hollowListLikeType" @click="dianzan(item.hollowListId)">
								<image src="https://sanfuzhide.oss-cn-hangzhou.aliyuncs.com/circle/zan-active.png" mode=""></image>
							</view>
							<view class="ri" >
								{{likeNum}}
							</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "treeHole",
		props: {
			item: Object,
			status: Number
		},
		data() {
			return {
				zanQurey:{
					id:0,
				},
				likeNum:this.item.hollowListLike,
				commentNum: this.item.hollowCommentNum
			};
		},
		watch:{
			item(){
				this.likeNum =this.item.hollowListLike,
				this.commentNum = this.item.hollowCommentNum
			},
		},
		methods:{
			//图片预览
			preview(i){
				uni.previewImage({
					current: this.item.hollowCommentContentList[i],
					urls: this.item.hollowCommentContentList
				})
			},
			//跳转至详情页
			link(item){
				console.log(this.item.hollowListId)
				uni.setStorageSync('pageNum',this.item.hollowListId)
				if(this.status == 0){
					uni.navigateTo({
						url: '/pagesB/treeHoleDetail/treeHoleDetail'
					})
				}else if(this.status == 1){
					return
				}
			},
			async dianzan(e){
				console.log(this.item)
				if(this.$login()){
					this.zanQurey.id = e
				let {data,code} = await this.$post('/hollowList/hollowLike',this.zanQurey)
				if(code == 200){
					uni.setStorageSync('likeId2',e)
					this.$emit('zan')
				}
				}else{
					uni.navigateTo({
						url: '../../pages/login/login'
					})
				}
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.item {
		background: #FFFFFF;
		box-shadow: 0rpx 0rpx 15rpx 0rpx rgba(94, 94, 94, 0.1);
		border-radius: 24rpx;
		width: 690rpx;
		padding: 30rpx;
		margin-bottom: 30rpx;
		margin-left: 30rpx;

		.outer {
			.left {
				width: 80rpx;
				height: 80rpx;
				border-radius: 50%;
				overflow: hidden;
				margin-right: 20rpx;
			}

			.right {
				width: 100%;

				.top {
					font-weight: 500;
					color: #003D5F;
					font-size: 32rpx;
					margin-top: 10rpx;
				}

				.texte {
					font-weight: 500;
					font-size: 28rpx;
					margin: 20rpx 0 10rpx;
					width: 490rpx;
					word-wrap: break-word;
					
				}

				.btmimg {
					.list:after {
					content: "";
					flex: auto;
					}
					.list{
						display: flex;
						flex-wrap: wrap;
						flex: 3;
						width: 550rpx;
					}
					.icon {
						width: 168rpx;
						height: 168rpx;
						margin: 20rpx 15rpx 0 0;
					}
					.video {
						width: 100%;
						height: 268rpx;
						border-radius: 8rpx;
						overflow: hidden;
						margin-top: 30rpx;

						video {
							width: 100%;
							height: 100%;
						}
					}
				}
				.positioning{
					margin-top: 20rpx;
					font-weight: 500;
					color: #999999;
					font-size: 24rpx;
					.city{
						.le {
							width: 36rpx;
							height: 36rpx;
							margin-right: 20rpx;
						}
						.ri {
							font-weight: 500;
							color: #333333;
							font-size: 28rpx;
						}
					}
				}
			}
		}
	}
</style>
